<?php
/**
 * +----------------------------------------------------------------------
 * | Author: 罗极
 * +----------------------------------------------------------------------
 * | Description: Error404View.php
 * +----------------------------------------------------------------------
 * | User: Administrator Date: 8/24/ 0024 Time: 10:05
 * +----------------------------------------------------------------------
 */
namespace Framework\View;

use Framework\Response\Constant\HttpCode;
use Framework\View\Abstracts\ErrorViewAbstract;

class Error404View extends ErrorViewAbstract
{
    public static $defaultHtml = "<h1 align='center'>404 NotFound</h1><hr /><div align='center'>{[Apache|nginx] ver:[xx.xx]}</div>";


    public static function trigger(string $errorMsg, string $viewPath = '')
    {
        self::setHttpCode();

        if(!file_exists($viewPath)) {
            echo self::$defaultHtml .'<p>'. $errorMsg . '</p>';
        } else {
            include $viewPath;
        }
        exit;
    }

    public static function setHttpCode()
    {
        header(HttpCode::Status[404]);
    }
}